﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Xml.Linq;
using System.Data.SqlClient;

namespace pcsse.BBS
{
    public partial class Subject : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["ID"] != null)
            {
                if (Convert.ToInt32(Session["Priority"]) >= 3)
                {
                    SubjectView1.Visible = false;
                    SubjectView2.Visible = true;
                    Panel2.Visible = true;
                }
            }
            else 
                Response.Redirect("..\\");

        }

        protected void Button4_Click(object sender, EventArgs e)
        {
            if (TextBox1.Text == "")
                return;
            string sqlstr = "INSERT INTO T_SUBJECT(SUBJECT,DESCRIBE,TIME) VALUES(@SUBJECT,@DESCRIBE,@TIME)";
            SqlCommand cmd = new SqlCommand();
            cmd.CommandText = sqlstr;
            cmd.Parameters.Add("@SUBJECT", TextBox1.Text);
            cmd.Parameters.Add("@DESCRIBE", TextBox2.Text);
            cmd.Parameters.Add("@TIME", DateTime.Now.ToString());
            db_base.getDBhandle().ExecuteCmd(cmd);
            Panel2.Visible = false;
            Response.Redirect(Request.Url.ToString());
        }

        protected void LinkButton1_Click(object sender, EventArgs e)
        {
            if (Panel2.Visible == false)
                Panel2.Visible = true;
        }
       
    }
}
